import time


def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data


a = read2list("m1_sorted.txt")
c = read2list("m2_reverse.txt")
d = read2list("m3_shuffle.txt")
t_start = time.time()
for i in range(len(a)):
    f = 0
    for k in range(len(a)-1):
        if a[k] > a[k + 1]:
            b = a[k]
            a[k] = a[k + 1]
            a[k + 1] = b
            f = 1
    if f == 0:
        break
t_finish = time.time()
print("Время", round((t_finish-t_start)*1000))
t_start = time.time()
for i in range(len(c)):
    f = 0
    for k in range(len(c)-1):
        if c[k] > c[k + 1]:
            b = c[k]
            c[k] = c[k + 1]
            c[k + 1] = b
            f = 1
    if f == 0:
        break
t_finish = time.time()
print("Время", round((t_finish-t_start)*1000))
t_start = time.time()
for i in range(len(d)):
    f = 0
    for k in range(len(d)-1):
        if d[k] > d[k + 1]:
            b = d[k]
            d[k] = d[k + 1]
            d[k + 1] = b
            f = 1
    if f == 0:
        break
t_finish = time.time()
print("Время", round((t_finish-t_start)*1000))
